package formularios;

import dao.*;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import negocios.Aluno;
import negocios.Livro;
import negocios.Locacao;

public final class LocacaoAluno extends javax.swing.JFrame {

    DefaultTableModel tmAluno = new DefaultTableModel(null, new String[]{"id", "nome", "Serie", "turma", "curso"}); // tmautor = tmContato
    List<Aluno> Aluno; // autor = contato;
    ListSelectionModel lsmAluno;
    DefaultTableModel tmLivro = new DefaultTableModel(null, new String[]{"Titulo", "Genero", "Tipo", "Tombamento", "Id"}); // tmautor = tmContato
    List<Livro> Livro; // autor = contato;
    ListSelectionModel lsmLivro; // lsmautor = lsmContato
    public int num;

    /** Creates new form Locacao */
    public LocacaoAluno() throws SQLException {
        initComponents();
        setExtendedState(MAXIMIZED_BOTH);
        java.util.Date mytec = new java.util.Date();
        SimpleDateFormat formataData = new SimpleDateFormat("yyyy-MM-dd");
        jL_data_saida.setText(formataData.format(mytec));
        jTFid.setEditable(false);
        jTFaluno.setEditable(false);
        jTFcurso.setEditable(false);
        jTFserie.setEditable(false);
        jTFturma.setEditable(false);
        jT_id_livro.setEditable(false);
        jTFnum.setEditable(false);
        jTFtitulo.setEditable(false);
        jTFgenero.setEditable(false);
        jTFtipo.setEditable(false);
        listarAluno();
        listarLivro();

    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jTF_pesquisarAluno = new javax.swing.JTextField();
        jBbuscar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jLcurso = new javax.swing.JLabel();
        jTFcurso = new javax.swing.JTextField();
        jTFturma = new javax.swing.JTextField();
        jLturma = new javax.swing.JLabel();
        jLserie = new javax.swing.JLabel();
        jTFserie = new javax.swing.JTextField();
        jTFaluno = new javax.swing.JTextField();
        jLaluno = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTFid = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jTF_pesquisaLivro = new javax.swing.JTextField();
        jB_pesquisaLivro = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTabela2 = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        jLtipo = new javax.swing.JLabel();
        jLgenero = new javax.swing.JLabel();
        jLtombamento = new javax.swing.JLabel();
        jLtitulo = new javax.swing.JLabel();
        jTFgenero = new javax.swing.JTextField();
        jTFtitulo = new javax.swing.JTextField();
        jTFnum = new javax.swing.JTextField();
        jTFtipo = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jT_id_livro = new javax.swing.JTextField();
        jPanel6 = new javax.swing.JPanel();
        realizar_locacao = new javax.swing.JButton();
        jB_sair = new javax.swing.JButton();
        jL_data_saida = new javax.swing.JLabel();
        jTF_data_devolucacao = new javax.swing.JFormattedTextField();

        jLabel1.setText("jLabel1");

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("SGB (Sistema Gerenciador da Biblioteca)");

        jPanel3.setBackground(new java.awt.Color(204, 255, 204));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true), "Locação", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(0, 102, 0))); // NOI18N

        jPanel1.setBackground(new java.awt.Color(204, 255, 204));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true), "Aluno", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(0, 102, 0))); // NOI18N

        jTF_pesquisarAluno.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));
        jTF_pesquisarAluno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTF_pesquisarAlunoActionPerformed(evt);
            }
        });
        jTF_pesquisarAluno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTF_pesquisarAlunoKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTF_pesquisarAlunoKeyReleased(evt);
            }
        });

        jBbuscar.setBackground(new java.awt.Color(204, 255, 204));
        jBbuscar.setForeground(new java.awt.Color(0, 102, 0));
        jBbuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/Figura1.PNG"))); // NOI18N
        jBbuscar.setText("Buscar");
        jBbuscar.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(0, 102, 0), new java.awt.Color(255, 255, 255)), new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 1, true)));
        jBbuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBbuscarActionPerformed(evt);
            }
        });

        jTable.setBackground(new java.awt.Color(204, 255, 204));
        jTable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));
        jTable.setForeground(new java.awt.Color(0, 102, 0));
        jTable.setModel(tmAluno);
        jTable.setGridColor(new java.awt.Color(0, 102, 0));
        jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        lsmAluno = jTable.getSelectionModel();
        lsmAluno.addListSelectionListener(new ListSelectionListener(){
            public void valueChanged(ListSelectionEvent e){
                if(! e.getValueIsAdjusting()){
                    JTTabelaLinhaSelecionada(jTable);
                }
            }
        });
        jScrollPane1.setViewportView(jTable);

        jPanel5.setBackground(new java.awt.Color(204, 255, 204));
        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true), "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(0, 102, 0)));

        jLcurso.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLcurso.setForeground(new java.awt.Color(0, 102, 0));
        jLcurso.setText("Curso:");

        jTFcurso.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jTFcurso.setForeground(new java.awt.Color(0, 102, 0));
        jTFcurso.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));

        jTFturma.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jTFturma.setForeground(new java.awt.Color(0, 102, 0));
        jTFturma.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));

        jLturma.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLturma.setForeground(new java.awt.Color(0, 102, 0));
        jLturma.setText("Turma:");

        jLserie.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLserie.setForeground(new java.awt.Color(0, 102, 0));
        jLserie.setText("Série:");

        jTFserie.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jTFserie.setForeground(new java.awt.Color(0, 102, 0));
        jTFserie.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));

        jTFaluno.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jTFaluno.setForeground(new java.awt.Color(0, 102, 0));
        jTFaluno.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));

        jLaluno.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLaluno.setForeground(new java.awt.Color(0, 102, 0));
        jLaluno.setText("Aluno(a):");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(0, 102, 0));
        jLabel3.setText("Id:");

        jTFid.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jTFid.setForeground(new java.awt.Color(0, 102, 0));
        jTFid.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLturma)
                    .addComponent(jLserie)
                    .addComponent(jLaluno)
                    .addComponent(jLcurso)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTFserie, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTFturma, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTFaluno, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                    .addComponent(jTFcurso, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTFid))
                .addGap(157, 157, 157))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLaluno, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jTFaluno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLserie, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jTFserie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLturma)
                    .addComponent(jTFturma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFcurso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLcurso, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jTF_pesquisarAluno, javax.swing.GroupLayout.DEFAULT_SIZE, 506, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jBbuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(20, 20, 20))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 357, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(120, 120, 120))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTF_pesquisarAluno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBbuscar))
                .addGap(20, 20, 20)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(48, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jBbuscar, jTF_pesquisarAluno});

        jPanel2.setBackground(new java.awt.Color(204, 255, 204));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true), "Livro", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(0, 102, 0))); // NOI18N

        jTF_pesquisaLivro.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));
        jTF_pesquisaLivro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTF_pesquisaLivroActionPerformed(evt);
            }
        });
        jTF_pesquisaLivro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTF_pesquisaLivroKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTF_pesquisaLivroKeyReleased(evt);
            }
        });

        jB_pesquisaLivro.setBackground(new java.awt.Color(204, 255, 204));
        jB_pesquisaLivro.setForeground(new java.awt.Color(0, 102, 0));
        jB_pesquisaLivro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/Figura1.PNG"))); // NOI18N
        jB_pesquisaLivro.setText("Buscar");
        jB_pesquisaLivro.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(0, 102, 0), new java.awt.Color(255, 255, 255)), new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 1, true)));
        jB_pesquisaLivro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jB_pesquisaLivroActionPerformed(evt);
            }
        });

        jTabela2.setBackground(new java.awt.Color(204, 255, 204));
        jTabela2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));
        jTabela2.setForeground(new java.awt.Color(0, 102, 0));
        jTabela2.setModel(tmLivro);
        jTabela2.setGridColor(new java.awt.Color(0, 102, 0));
        jTabela2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        lsmLivro = jTabela2.getSelectionModel();
        lsmLivro.addListSelectionListener(new ListSelectionListener(){
            public void valueChanged(ListSelectionEvent e){
                if(! e.getValueIsAdjusting()){
                    JTTabelaLinhaSelecionada2(jTabela2);
                }
            }
        }
    );
    jScrollPane2.setViewportView(jTabela2);

    jPanel4.setBackground(new java.awt.Color(204, 255, 204));
    jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true), "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(0, 102, 0)));

    jLtipo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jLtipo.setForeground(new java.awt.Color(0, 102, 0));
    jLtipo.setText("Tipo:");

    jLgenero.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jLgenero.setForeground(new java.awt.Color(0, 102, 0));
    jLgenero.setText("Gênero:");

    jLtombamento.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jLtombamento.setForeground(new java.awt.Color(0, 102, 0));
    jLtombamento.setText("Tombamento:");

    jLtitulo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jLtitulo.setForeground(new java.awt.Color(0, 102, 0));
    jLtitulo.setText("Título:");

    jTFgenero.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jTFgenero.setForeground(new java.awt.Color(0, 102, 0));
    jTFgenero.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));

    jTFtitulo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jTFtitulo.setForeground(new java.awt.Color(0, 102, 0));
    jTFtitulo.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));

    jTFnum.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jTFnum.setForeground(new java.awt.Color(0, 102, 0));
    jTFnum.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));
    jTFnum.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTFnumActionPerformed(evt);
        }
    });

    jTFtipo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jTFtipo.setForeground(new java.awt.Color(0, 102, 0));
    jTFtipo.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));

    jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jLabel4.setForeground(new java.awt.Color(0, 102, 0));
    jLabel4.setText("Id:");

    jT_id_livro.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jT_id_livro.setForeground(new java.awt.Color(0, 102, 0));
    jT_id_livro.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));
    jT_id_livro.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jT_id_livroActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(
        jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel4Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLtipo)
                .addComponent(jLtitulo)
                .addComponent(jLtombamento)
                .addComponent(jLabel4)
                .addComponent(jLgenero))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jTFnum, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
                .addComponent(jTFtitulo, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
                .addComponent(jTFtipo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
                .addComponent(jTFgenero, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
                .addComponent(jT_id_livro, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE))
            .addContainerGap())
    );
    jPanel4Layout.setVerticalGroup(
        jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel4Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel4)
                .addComponent(jT_id_livro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jLtombamento)
                .addComponent(jTFnum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLtitulo)
                .addComponent(jTFtitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jTFgenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLgenero, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLtipo)
                .addComponent(jTFtipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(20, 20, 20))
    );

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                            .addComponent(jTF_pesquisaLivro, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jB_pesquisaLivro, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGap(134, 134, 134)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addContainerGap())
    );
    jPanel2Layout.setVerticalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jTF_pesquisaLivro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jB_pesquisaLivro))
            .addGap(18, 18, 18)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jB_pesquisaLivro, jTF_pesquisaLivro});

    jPanel6.setBackground(new java.awt.Color(204, 255, 204));
    jPanel6.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true));

    realizar_locacao.setBackground(new java.awt.Color(204, 255, 204));
    realizar_locacao.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    realizar_locacao.setForeground(new java.awt.Color(0, 102, 0));
    realizar_locacao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/Figura12.png"))); // NOI18N
    realizar_locacao.setText("Realizar Locação");
    realizar_locacao.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(0, 102, 0), new java.awt.Color(255, 255, 255)), new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 1, true)));
    realizar_locacao.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            realizar_locacaoActionPerformed(evt);
        }
    });

    jB_sair.setBackground(new java.awt.Color(204, 255, 204));
    jB_sair.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jB_sair.setForeground(new java.awt.Color(0, 102, 0));
    jB_sair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/Figura6.png"))); // NOI18N
    jB_sair.setText("Voltar");
    jB_sair.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(0, 102, 0), new java.awt.Color(255, 255, 255)), new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 1, true)));
    jB_sair.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jB_sairActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
    jPanel6.setLayout(jPanel6Layout);
    jPanel6Layout.setHorizontalGroup(
        jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
            .addContainerGap(26, Short.MAX_VALUE)
            .addComponent(jB_sair, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(35, 35, 35)
            .addComponent(realizar_locacao, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap())
    );
    jPanel6Layout.setVerticalGroup(
        jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jB_sair, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(realizar_locacao, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap())
    );

    jL_data_saida.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jL_data_saida.setForeground(new java.awt.Color(0, 102, 0));
    jL_data_saida.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jL_data_saida.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true), "Data de saida", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

    jTF_data_devolucacao.setBackground(new java.awt.Color(204, 255, 204));
    jTF_data_devolucacao.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 2, true), "Data de Devolução", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N
    jTF_data_devolucacao.setForeground(new java.awt.Color(0, 102, 0));
    try {
        jTF_data_devolucacao.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####-##-##")));
    } catch (java.text.ParseException ex) {
        ex.printStackTrace();
    }
    jTF_data_devolucacao.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jTF_data_devolucacao.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

    javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(
        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel3Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                    .addGap(0, 654, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(695, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                    .addGap(0, 510, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jL_data_saida, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(jTF_data_devolucacao, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGap(513, 513, 513))))
    );
    jPanel3Layout.setVerticalGroup(
        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel3Layout.createSequentialGroup()
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jTF_data_devolucacao, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)
                .addComponent(jL_data_saida, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap())
    );

    jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jPanel1, jPanel2});

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    );

    pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBbuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBbuscarActionPerformed

        try {
            listarAluno();
        } catch (SQLException ex) {
        }
    }//GEN-LAST:event_jBbuscarActionPerformed

    private void jB_pesquisaLivroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jB_pesquisaLivroActionPerformed
        try {
            listarLivro();
        } catch (SQLException ex) {
            Logger.getLogger(LocacaoAluno.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jB_pesquisaLivroActionPerformed

    private void realizar_locacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_realizar_locacaoActionPerformed
        try {
            if (verificaDados() && verificadata()) {
                try {
                    locacao();
                    JOptionPane.showMessageDialog(null, "Locação realizada com sucesso !");
                    limpacampos();
                } catch (SQLException ex) {
                    Logger.getLogger(LocacaoAluno.class.getName()).log(Level.SEVERE, null, ex);
                }

            } else {
                JOptionPane.showMessageDialog(null, "Campos não preenchidos !");
                JOptionPane.showMessageDialog(null,"A data não pode ser anterior ao dia de saida !");
            }
        } catch (ParseException ex) {
            Logger.getLogger(LocacaoAluno.class.getName()).log(Level.SEVERE, null, ex);
        }


    }//GEN-LAST:event_realizar_locacaoActionPerformed

    public void locacao() throws SQLException {
        Locacao a = new Locacao();
        a.id_aluno = Integer.parseInt(jTFid.getText());
        a.id_livro = Integer.parseInt(jT_id_livro.getText());
        a.data_devolucao = jTF_data_devolucacao.getText();
        a.data_saida = (jL_data_saida.getText());
        LocacaoDAO dao = new LocacaoDAO();
        dao.adicionar(a);
    }
    private void jB_sairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jB_sairActionPerformed
        dispose();

    }//GEN-LAST:event_jB_sairActionPerformed

    private void jTFnumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFnumActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTFnumActionPerformed

    private void jTF_pesquisarAlunoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTF_pesquisarAlunoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTF_pesquisarAlunoActionPerformed

    private void jTF_pesquisarAlunoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTF_pesquisarAlunoKeyPressed
    }//GEN-LAST:event_jTF_pesquisarAlunoKeyPressed

    private void jTF_pesquisaLivroKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTF_pesquisaLivroKeyPressed
    }//GEN-LAST:event_jTF_pesquisaLivroKeyPressed

    private void jTF_pesquisaLivroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTF_pesquisaLivroActionPerformed
    }//GEN-LAST:event_jTF_pesquisaLivroActionPerformed

    private void jT_id_livroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jT_id_livroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jT_id_livroActionPerformed

    private void jTF_pesquisarAlunoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTF_pesquisarAlunoKeyReleased
        try {
            listarAluno();
        } catch (SQLException ex) {
            Logger.getLogger(LocacaoAluno.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jTF_pesquisarAlunoKeyReleased

    private void jTF_pesquisaLivroKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTF_pesquisaLivroKeyReleased
        try {
            listarLivro();
        } catch (SQLException ex) {
            Logger.getLogger(LocacaoAluno.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jTF_pesquisaLivroKeyReleased
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jB_pesquisaLivro;
    private javax.swing.JButton jB_sair;
    private javax.swing.JButton jBbuscar;
    private javax.swing.JLabel jL_data_saida;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLaluno;
    private javax.swing.JLabel jLcurso;
    private javax.swing.JLabel jLgenero;
    private javax.swing.JLabel jLserie;
    private javax.swing.JLabel jLtipo;
    private javax.swing.JLabel jLtitulo;
    private javax.swing.JLabel jLtombamento;
    private javax.swing.JLabel jLturma;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JFormattedTextField jTF_data_devolucacao;
    private javax.swing.JTextField jTF_pesquisaLivro;
    private javax.swing.JTextField jTF_pesquisarAluno;
    private javax.swing.JTextField jTFaluno;
    private javax.swing.JTextField jTFcurso;
    private javax.swing.JTextField jTFgenero;
    private javax.swing.JTextField jTFid;
    private javax.swing.JTextField jTFnum;
    private javax.swing.JTextField jTFserie;
    private javax.swing.JTextField jTFtipo;
    private javax.swing.JTextField jTFtitulo;
    private javax.swing.JTextField jTFturma;
    private javax.swing.JTextField jT_id_livro;
    private javax.swing.JTable jTabela2;
    private javax.swing.JTable jTable;
    private javax.swing.JButton realizar_locacao;
    // End of variables declaration//GEN-END:variables

    protected void listarAluno() throws SQLException {
        AlunoDAO dao = new AlunoDAO();
        Aluno = dao.Buscar(jTF_pesquisarAluno.getText() + "%");
        mostraPesquisa(Aluno);
    }

    public boolean verificaDados() {
        if (!jTFid.getText().equals("") && !jT_id_livro.getText().equals("") && !jTF_data_devolucacao.getText().equals("")) {
            return true;
        } else {
            return false;
        }
    }

    private void mostraPesquisa(List<Aluno> Aluno) {
        // Zerando a lista de pesquisa !
        while (tmAluno.getRowCount() > 0) {
            tmAluno.removeRow(0);
        }
        if (Aluno.isEmpty()) {
        } else {
            String[] linha = new String[]{null, null, null, null, null};
            for (int i = 0; i < Aluno.size(); i++) {
                tmAluno.addRow(linha);
                tmAluno.setValueAt(Aluno.get(i).getId(), i, 0);
                tmAluno.setValueAt(Aluno.get(i).getNome(), i, 1);
                tmAluno.setValueAt(Aluno.get(i).getSerie(), i, 2);
                tmAluno.setValueAt(Aluno.get(i).getTurma(), i, 3);
                tmAluno.setValueAt(Aluno.get(i).getCurso(), i, 4);
            }
        }
    }

    private void JTTabelaLinhaSelecionada(JTable tabela) {
        if (jTable.getSelectedRow() != -1) {

            jTFid.setText(String.valueOf(Aluno.get(tabela.getSelectedRow()).getId()));
            jTFaluno.setText((Aluno.get(tabela.getSelectedRow()).getNome()));
            jTFserie.setText((Aluno.get(tabela.getSelectedRow()).getSerie()));
            jTFturma.setText((Aluno.get(tabela.getSelectedRow()).getTurma()));
            jTFcurso.setText((Aluno.get(tabela.getSelectedRow()).getCurso()));
        } else {
            jTFid.setText("");
            jTFaluno.setText("");
            jTFserie.setText("");
            jTFturma.setText("");
            jTFcurso.setText("");
        }
    }

    protected void listarLivro() throws SQLException {
        LivroDAO dao = new LivroDAO();
        Livro = dao.Buscar(jTF_pesquisaLivro.getText() + "%");
        mostraPesquisaLivro(Livro);
    }

    private void mostraPesquisaLivro(List<Livro> Livro) {
        while (tmLivro.getRowCount() > 0) {
            tmLivro.removeRow(0);

        }
        if (Livro.isEmpty()) {
        } else {
            String[] linha = new String[]{null, null, null, null, null};
            for (int i = 0; i < Livro.size(); i++) {
                tmLivro.addRow(linha);

                tmLivro.setValueAt(Livro.get(i).getTitulo(), i, 0);
                tmLivro.setValueAt(Livro.get(i).getGenero(), i, 1);
                tmLivro.setValueAt(Livro.get(i).getTipo(), i, 2);
                tmLivro.setValueAt(Livro.get(i).getNum(), i, 3);
                tmLivro.setValueAt(Livro.get(i).getId(), i, 4);
            }
        }
    }

    private void JTTabelaLinhaSelecionada2(JTable tabela) {
        if (jTabela2.getSelectedRow() != -1) {
            jTFtitulo.setText(Livro.get(tabela.getSelectedRow()).getTitulo());
            jTFgenero.setText(Livro.get(tabela.getSelectedRow()).getGenero());
            jTFtipo.setText(Livro.get(tabela.getSelectedRow()).getTipo());
            jTFnum.setText(String.valueOf(Livro.get(tabela.getSelectedRow()).getNum()));
            jT_id_livro.setText(String.valueOf(Livro.get(tabela.getSelectedRow()).getId()));
        } else {
            jT_id_livro.setText("");
            jTFtitulo.setText("");
            jTFgenero.setText("");
            jTFnum.setText("");
            jTFtipo.setText("");
        }
    }

    private void limpacampos() {
        jTFid.setText("");
        jTFaluno.setText("");
        jTFserie.setText("");
        jTFturma.setText("");
        jTFcurso.setText("");
        jT_id_livro.setText("");
        jTFtitulo.setText("");
        jTFgenero.setText("");
        jTFnum.setText("");
        jTFtipo.setText("");
        jTF_data_devolucacao.setText("");
    }

    public boolean verificadata() throws ParseException {
        java.util.Date mytec = new java.util.Date();
        SimpleDateFormat formataData = new SimpleDateFormat("yyyy-MM-dd");
        Date dia_saida = formataData.parse(jL_data_saida.getText());
        Date dia_devolucao = formataData.parse(jTF_data_devolucacao.getText());
        if ((dia_saida).before(dia_devolucao)) {
            return true;

        } else {
            return false;

        }


    }
}